<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-control" content="no-cache" />
    <meta http-equiv="Cache" content="no-cache" />
    <link rel="stylesheet" href="../../javascript/plug-ins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../../css/style.css" />
    <script src="../../javascript/jquery.js"></script>
    <script type="text/javascript" src="../../javascript/plug-ins/layui/layui.js"></script>
    <script type="text/javascript" src="../../javascript/plug-ins/pagination.js"></script>

    <script src="../../js/zyrpublic.js?v=2"></script>
    <script src="../../js/zyrfunction.js?v=2"></script>
    <script>
        document.write(
            "<script type='text/javascript' src='js/SpellList.js?v=" +
            Math.random() +
            "'></scri" +
            "pt>"
        );
    </script>
    <script src="../../javascript/vue.js"></script>
    <script src="../../javascript/elementui.js"></script>
    <script src="../../javascript/axios.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
</head>

<body>
    <div class="page-wrap" id="app">
        <section class="page-hd t">
            <header>
                <h5 class="title">
                    <a href="#" class="red">拼单列表</a>
                </h5>
            </header>
            <hr />
        </section>

        <div class="flex flex-wrap flex-col-6 form-group">
            <div class="box-child text-left margin_left10">
                <input onclick="DeleteInfoList(this);" data-info="DeleSpellInfo" type="button" value="批量删除"
                    class="btn btn-info" />
                <input onclick="window.location.href='addSpell.html'" type="button" value="添加" class="btn btn-info" />
            </div>
            <div class="box-child text-left" style="margin-left: 20px">
                活动商品状态：
                <select style="width: auto" id="activitiesState" onchange="SearchInfo()">
                    <option value="-1">请选择</option>
                    <option value="1">未开始</option>
                    <option value="2">进行中</option>
                    <option value="3">已结束</option>
                </select>
            </div>
            <div class="box-child text-left" style="margin-left: 20px; display: flex; align-items: center">
                <span class="font_size16 red" style="margin-right: 20px">首页开启</span>
                <el-switch v-model="spellVal" active-color="#13ce66" inactive-color="#000"
                    @change="handleSwitchChange(spellVal)">
                </el-switch>
            </div>
            <div class="box-child text-left" style="margin-left: 20px">
                <el-button @click="handleToCountDown" type="primary">倒计时设置</el-button>
            </div>
        </div>

        <div class="panel panel-default" style="text-align: center">
            <table class="table table-bordered" id="tableInfo">
                <thead>
                    <tr>
                        <th>
                            <input type="checkbox" class="aceParent" id="all" />
                        </th>
                        <th>商品图片</th>
                        <th>商品名称</th>
                        <th>拼团开始时间</th>
                        <th>拼团结束时间</th>
                        <th>等待时间/小时</th>
                        <th>满足人数</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>

            <div id="page"></div>
        </div>
    </div>
    <!---page-wrap------>
</body>
<script>
    var instance = axios.create({
        baseURL: httpurl,
        timeout: 3000,
        headers: {
            'Content-Type': 'application/json',
            "Authorization": GetTokenInfo()
        }
    })
</script>
<script>
    var app = new Vue({
        el: "#app",
        data() {
            return {
                spellVal: false,
            };
        },

        mounted() {

            this.getquerySysDicList()

        },

        methods: {

            // 倒计时设置
            handleToCountDown() {
                window.location.href = "../Cpike/CountDown.html?id=2"
            },
            //
            getquerySysDicList() {
                instance.get('querySysDicList?type=activity.open.status').then(res => {
                    console.log(res);
                    if (res.data.rtnCode == 200) {
                        console.log(res.data.data);
                        let list = res.data.data
                        this.statusList = list
                        list.forEach(v => {
                            if (v.code == 2) {
                                this.$nextTick(() => {
                                    this.spellVal = v.value == 1 ? true : false
                                })
                            }
                        })
                    }
                })
            },

            getquerySysDicOne(type) {
                let query = {
                    code: 2,
                    value: type
                }
                instance.post(`/updateActivityState`,
                    query
                ).then(res => {
                    if (res.data.rtnCode == 200) {
                        this.$message.success('修改成功');
                    }

                    if (res.data.rtnCode == 500) {
                        this.spellVal = false
                        console.log('111');
                        this.$message.error('其他活动已开启');
                    }
                }).catch(err => {
                    console.log(err);
                })
            },

            handleSwitchChange(e) {
                let type = e == true ? 1 : 0
                this.getquerySysDicOne(type)
                // if (cpikeFlag) {
                //     this.spellVal = false;
                //     this.$message.error("拼单和秒杀不能同时开启");
                //     return;
                // }

            },


        },
    });
</script>

</html>